package com.ruoyi.iot.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.iot.domain.IotRulesTrigger;
import com.ruoyi.iot.mapper.IotRulesTriggerMapper;
import com.ruoyi.iot.service.IIotRulesTriggerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 规则触发器Service业务层处理
 *
 * @author ruoyi
 * @date 2025-03-28
 */
@Service
public class IotRulesTriggerServiceImpl implements IIotRulesTriggerService {
    @Autowired
    private IotRulesTriggerMapper iotRulesTriggerMapper;

    /**
     * 查询规则触发器
     *
     * @param triggerId 规则触发器主键
     * @return 规则触发器
     */
    @Override
    public IotRulesTrigger selectIotRulesTriggerByTriggerId(Long triggerId) {
        return iotRulesTriggerMapper.selectIotRulesTriggerByTriggerId(triggerId);
    }

    /**
     * 查询规则触发器列表
     *
     * @param iotRulesTrigger 规则触发器
     * @return 规则触发器
     */
    @Override
    public List<IotRulesTrigger> selectIotRulesTriggerList(IotRulesTrigger iotRulesTrigger) {
        return iotRulesTriggerMapper.selectIotRulesTriggerList(iotRulesTrigger);
    }

    /**
     * 新增规则触发器
     *
     * @param iotRulesTrigger 规则触发器
     * @return 结果
     */
    @Override
    public int insertIotRulesTrigger(IotRulesTrigger iotRulesTrigger) {
        iotRulesTrigger.setCreateTime(DateUtils.getNowDate());
        return iotRulesTriggerMapper.insertIotRulesTrigger(iotRulesTrigger);
    }

    /**
     * 修改规则触发器
     *
     * @param iotRulesTrigger 规则触发器
     * @return 结果
     */
    @Override
    public int updateIotRulesTrigger(IotRulesTrigger iotRulesTrigger) {
        iotRulesTrigger.setUpdateTime(DateUtils.getNowDate());
        return iotRulesTriggerMapper.updateIotRulesTrigger(iotRulesTrigger);
    }

    /**
     * 批量删除规则触发器
     *
     * @param triggerIds 需要删除的规则触发器主键
     * @return 结果
     */
    @Override
    public int deleteIotRulesTriggerByTriggerIds(Long[] triggerIds) {
        return iotRulesTriggerMapper.deleteIotRulesTriggerByTriggerIds(triggerIds);
    }

    /**
     * 删除规则触发器信息
     *
     * @param triggerId 规则触发器主键
     * @return 结果
     */
    @Override
    public int deleteIotRulesTriggerByTriggerId(Long triggerId) {
        return iotRulesTriggerMapper.deleteIotRulesTriggerByTriggerId(triggerId);
    }

    /**
     * 根据规则id查询规则触发器
     *
     * @param ruleId 规则id
     * @return com.ruoyi.iot.IotRulesTrigger
     * @author Howe
     * @since 2025/6/9 10:53
     **/
    @Override
    public IotRulesTrigger selectIotRulesTriggerByRuleId(Long ruleId) {
        return iotRulesTriggerMapper.selectIotRulesTriggerByRuleId(ruleId);
    }


    /**
    * 根据触发器，生成规则SQL
    * @param iotRulesTrigger 触发器
    * @return
    * @author Howe
    * @since 2025/6/9 10:55
    **/
    @Override
    public String generateRuleSql(IotRulesTrigger iotRulesTrigger) {

        return null;
    }
}
